package org.spring.springboot.util;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.io.File;
import java.nio.file.Path;
import java.util.HashMap;

public class CreateQR {
    public CreateQR() {
    }

    public static void make(Integer width, Integer height, String url, String filename) {
        HashMap<EncodeHintType, Comparable> hm = new HashMap();
        hm.put(EncodeHintType.CHARACTER_SET, "UTF-8");
        hm.put(EncodeHintType.MARGIN, 2);
        hm.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);

        try {
            BitMatrix bm = (new MultiFormatWriter()).encode(url, BarcodeFormat.QR_CODE, width, height, hm);
            File file = new File(filename);
            MatrixToImageWriter.writeToFile(bm, "png", file);
        } catch (Exception var7) {
            var7.printStackTrace();
        }

    }
}
